﻿CREATE PROCEDURE [dbo].[proc_OpcoesRefeicoesLoadByRefeicao]
(
	@IdRefeicaoContratada bigint,
	@DataRefeicao date
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		o.[IdRefeicaoContratada],
		o.[DataRefeicao],
		o.[CodOpcao],
		o.[Descricao],
		o.[DataCriacao],
		o.[DataAlteracao],
		t.Descricao as DescricaoOpcao,
		t.DescricaoCurta as DescricaoCurtaOpcao,
		t.Simbolo as SimboloOpcao,
		t.Tipo as TipoOpcao
	FROM [OpcoesRefeicoes] o
			inner join Tipologias t on o.CodOpcao = t.Codigo and t.Tipo = 'TipoOpcao' 
	WHERE
		(o.[IdRefeicaoContratada] = @IdRefeicaoContratada) AND
		(o.[DataRefeicao] = @DataRefeicao)

	SET @Err = @@Error

	RETURN @Err
END
